<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var arr = [54, 38, 39, 11, 98, 77, 100, 83];
        var max = 0;//最大值的初始值必须是最小的
        var min = 100;//最小值的初始值必须是最大的
        var max_index = 0;
        var min_index = 0;
        for (var i = 0; i <= arr.length - 1; i++) {
            if (arr[i] > max) {
                max = arr[i];
                max_index = i;
            }
            if (arr[i] < min) {
                min = arr[i];
                min_index = i;
            }
        }
        console.log("下标为" + max_index + "的最大值" + max);
        console.log("下标为" + min_index + "的是最小值" + min);
    </script>
</body>

</html>